import draw.*;
import geometry.Posn;
import geometry.*;
import tester.*;
import java.util.*;
import colors.*;

class Star{
  int VEL = 8;
  int span;
  Posn location;
  int rad = 4;
  
  //draws a singluar, lonely star.
  boolean drawStar(Canvas c){
    return c.drawDisk(this.location, this.rad, new Yellow());
  }
  
  //Moves the star downwards and shortens span on one tick.
  Star onTick(){
    return new Star(this.span - 1, 
                    new Posn(this.location.x, this.location.y + this.VEL));
  }
  
  //has this star hit the MFMWG?
  boolean isFoundp(Mfmwg m){
    return Math.sqrt((this.location.x - m.location.x) * 
                     (this.location.x - m.location.x) +
                     (this.location.y - m.location.y) * 
                     (this.location.y - m.location.y)) <
                     (m.rad + this.rad);
  }
  
  //has this star hit the ground?
  boolean hitGroundp(){
    return this.location.y >= 300;
  }
  
  //makes a new star at a random x-pos, with a random lifespan, at the top of
  //the canvas.
  Star makeStar(){
    return new Star(new Random().nextInt() % 30 + 5,
                    new Posn(new Random().nextInt() % 195 + 5, 5));
  }
  
  Star(int span, Posn location) {
    this.span = span;
    this.location = location;
  }
   /*
TEMPLATE:
   FIELDS:
    ... this.VEL ...            --int
    ... this.location ...       --Posn
     ... this.span ...          --int
     ... this.rad ...           --int

    METHODS:
    ... this.onTick() ...             -- Star
    ... this.makeStar() ...           -- Star
    ... this.hitGroundp() ...         -- boolean
    ... this.isFoundp(Mfmwg m) ...    -- boolean
    ... this.drawStar(Canvas c) ...   -- boolean
    ... this.amIEmptyp() ...          -- boolean

    METHODS FOR FIELDS:
    n/a
*/ 
}